package org.aeon.colorfulplanebattle.flying.entity;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author: MissingAeon
 * @date: 2024/1/9 19:29
 * @description: 碰撞对
 */
public class CollisionPairs {
    private static BufferedImage read;          // 碰撞图片

    static {
        try {
            InputStream resource = Ship.class.getClassLoader().getResourceAsStream("img/qita/chahao.png");
            if (resource != null)
                read = ImageIO.read(resource);
        } catch (IOException e) {
        }
    }

    private final FlyObject obj1;                   // 碰撞物
    private final FlyObject obj2;                   // 碰撞物
    private int existenceTime;                      // 持续时间

    public CollisionPairs(FlyObject obj1, FlyObject obj2) {
        this.existenceTime = 5;
        this.obj1 = obj1;
        this.obj2 = obj2;
    }

    public void draw(Graphics g) {
        g.drawImage(read, obj1.getX(), obj1.getY(), 80, 80, null);
    }

    public FlyObject getObj1() {
        return obj1;
    }

    public FlyObject getObj2() {
        return obj2;
    }

    public int getExistenceTime() {
        return existenceTime;
    }

    public void setExistenceTime(int existenceTime) {
        this.existenceTime = existenceTime;
    }
}
